package com.tan.lbs.activity;

import com.tan.lbs.activity.R;
import com.tan.lbs.dao.GameDAO;
import com.tan.lbs.dao.ItemDAO;
import com.tan.lbs.dao.QuestDAO;
import com.tan.lbs.dao.impl.GameDAOImpl;
import com.tan.lbs.dao.impl.ItemDAOImpl;
import com.tan.lbs.dao.impl.QuestDAOImpl;
import com.tan.lbs.entity.Item;
import com.tan.lbs.entity.Quest;
import com.tan.lbs.util.Constants;
import com.tan.lbs.util.ResourceReader;
import com.tan.lbs.util.URLs;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

public class ItemDetailActivity extends Activity{
	@Override
	public void onCreate(Bundle savedInstanceState) {

		super.onCreate(savedInstanceState);
		setContentView(R.layout.itemdetail);
		
		Intent intent = getIntent();
		String itemID = intent.getStringExtra("itemID");
		String gameID = getSharedPreferences(Constants.PREFS_NAME, 0).getString("currentGameID", "");
		ItemDAO itemDAO = new ItemDAOImpl(this);
		Item item = itemDAO.readItem(itemID, gameID);
		
		Bitmap icon = ResourceReader.readImage(this,
				URLs.gameResourceLoc + gameID + "/"
						+ item.getIconID());
		

		
		ImageView itemIcon = (ImageView)findViewById(R.id.itemInfoIcon);
		itemIcon.setImageBitmap(icon);
		
		Bitmap containedMedia = ResourceReader.readImage(this,
				URLs.gameResourceLoc + gameID + "/"
						+ item.getContainedMediaID());
		
		ImageView itemMedia = (ImageView)findViewById(R.id.itemContainedMedia);
		itemMedia.setImageBitmap(containedMedia);
		

		
		((TextView)findViewById(R.id.itemInfotitle)).setText(item.getTitle());
		((TextView)findViewById(R.id.itemDisplayText)).setText(item.getDisplayText());
		
		
		
		((Button)findViewById(R.id.itemBackBtn)).setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				finish();
			}
			
		});
	}
}
